# -*-coding: utf-8 -*-
"""
    @Theme   : 
    @Time    : 2024/4/10 15:58
    @Author  : YamFish
    @Url     : https://www.zhihu.com/people/yamfish
"""
from flask_mail import Mail
from flask_ckeditor import CKEditor
from flask_moment import Moment
from flask_sqlalchemy import SQLAlchemy
from flask_bootstrap import Bootstrap5
from flask_login import LoginManager
from flask_wtf import CSRFProtect

mail = Mail()
moment = Moment()
db = SQLAlchemy()
ck_editor = CKEditor()
bootstrap = Bootstrap5()
login_manager = LoginManager()
csrf = CSRFProtect()


@login_manager.user_loader
def load_user(user_id):
    """Query user by id in the cookie"""
    from suzyblog.models import Admin
    user = Admin.query.get(user_id)
    return user


login_manager.login_view = 'auth.login'
login_manager.login_message = 'Please Login First!'
login_manager.login_message_category = 'warning'
